#ifndef __STDTHREAD_H_
#define __STDTHREAD_H_

#include <stdbool.h>

//线程
struct StdThread;
typedef struct StdThread Thread;

Thread* ThreadInit(void*(*func)(void*),void*arg);
void* ThreadJoin(Thread *t);
void ThreadDetach(Thread *t);
void ThreadCancel(Thread *t);
void ThreadExit();
bool IsCurrentThread(Thread *t);
void ClearThread(Thread *t);

//互斥锁
struct StdMutex;
typedef struct StdMutex Mutex;
Mutex * MutexInit();
void MutexLock(Mutex *m);
void MutexUnlock(Mutex *m);
bool MutexTryLock(Mutex *m,int seconds,int count);
void ClearMutex(Mutex *m);

//条件变量
struct StdConditionVar;
typedef struct StdConditionVar Cond;
Cond* CondInit();
void CondWait(Cond *c,Mutex *m);
void CondSignal(Cond *c);
void CondBroadcast(Cond *c);
void ClearCond(Cond *c);


//读写锁
struct StdRWMutex;
typedef struct StdRWMutex RWMutex;

RWMutex* RWMutexInit();
void RWReadLock(RWMutex *rw); //读锁上锁
void RWReadUnlock(RWMutex *rw); //读锁解锁
void RWWritelock(RWMutex *rw ); //写锁上锁 
void RWWriteUnlock(RWMutex *rw); //写锁解锁
void ClearRWMutex(RWMutex * rw);




#endif